package com.xuecheng.content.conver;

import com.xuecheng.content.model.dto.AddCourseDto;
import com.xuecheng.content.model.dto.CourseBaseInfoDto;
import com.xuecheng.content.model.dto.CourseTeacherDto;
import com.xuecheng.content.model.po.CourseBase;
import com.xuecheng.content.model.po.CourseMarket;
import com.xuecheng.content.model.po.CourseTeacher;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;

public class CourseBaseConverter {

    public CourseBase AddCourseDtoConverToCourseBase(AddCourseDto addCourseDto, CourseTeacherDto courseTeacher){

        CourseBase courseBaseInsert = new CourseBase();
        BeanUtils.copyProperties(addCourseDto,courseBaseInsert);
        courseBaseInsert.setCreateDate(LocalDateTime.now());         //设置创建时间
        courseBaseInsert.setChangeDate(LocalDateTime.now());         //设置修改时间
        courseBaseInsert.setCreatePeople(courseTeacher.getTeacherName());       //设置创建人
        courseBaseInsert.setChangePeople(courseTeacher.getTeacherName());       //初次创建及更新
        courseBaseInsert.setAuditStatus("202002");                  // 设置为未提交
        courseBaseInsert.setStatus("203001");                       // 设值为未发布
        return courseBaseInsert;
    }

    public CourseTeacher courseTeacherConverToCourseTeacherInsert(CourseTeacherDto courseTeacherDto){
        CourseTeacher courseTeacherInsert = new CourseTeacher();
        BeanUtils.copyProperties(courseTeacherDto,courseTeacherInsert);
        courseTeacherInsert.setCreateDate(LocalDateTime.now());
        return courseTeacherInsert;
    }

    public CourseBaseInfoDto courseBaseAndCourseMarketCoverToCourseBaseInfoDto(CourseMarket courseMarketInsert,CourseBase courseBaseInsert){
        CourseBaseInfoDto courseBaseInfoDto = new CourseBaseInfoDto();
        BeanUtils.copyProperties(courseMarketInsert,courseBaseInfoDto);
        BeanUtils.copyProperties(courseBaseInsert,courseBaseInfoDto);
        return courseBaseInfoDto;
    }

}















